package com.flash.BusinessData.service.impl;

import com.flash.BusinessData.entity.CashAccrued;
import com.flash.BusinessData.mapper.CashAccruedMapper;
import com.flash.BusinessData.service.CashAccruedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CashAccruedImpl implements CashAccruedService {
    @Autowired
    CashAccruedMapper   cashAccruedMapper;
    @Override
    public List<CashAccrued> CashAccruedSelect(int page,int limit,CashAccrued cashAccrued) {
        Map map = new HashMap();
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        map.put("strWhere",buildStrWhere(cashAccrued));
        return cashAccruedMapper.CashAccruedSelect(map);
    }

    public String buildStrWhere(CashAccrued cashAccrued){
        StringBuffer strWhere=new StringBuffer("");
        if(cashAccrued.getBusinessTime()!=null && !cashAccrued.getBusinessTime().equals(""))
        {
            strWhere.append(" and businessTime like '%" + cashAccrued.getBusinessTime() + "%'");
        }
        if (cashAccrued.getBusinessType()!=0 && cashAccrued.getBusinessType()<=4){
            strWhere.append(" and BusinessType =" + cashAccrued.getBusinessType() );
        }
        return strWhere.toString();
    }

    @Override
    public int  CashAccruedCount() {
        return cashAccruedMapper.CashAccruedCount();
    }

    @Override
    public int insertCashAccrued(CashAccrued cashAccrued) {
        return cashAccruedMapper.insertCashAccrued(cashAccrued);
    }

    @Override
    public int deleteCashAccrued(String cashAccruedId) {
        return cashAccruedMapper.deleteCashAccrued(cashAccruedId);
    }

    @Override
    public int updateCashAccrued(CashAccrued cashAccrued) {
        return cashAccruedMapper.updateCashAccrued(cashAccrued);
    }

    @Override
    public int deleteCashAccruedNew(CashAccrued cashAccrued) {
        return cashAccruedMapper.deleteCashAccruedNew(cashAccrued);
    }

    @Override
    public int deleteCashAccrueNews(CashAccrued cashAccrued) {
        return cashAccruedMapper.deleteCashAccrueNews(cashAccrued);
    }

}
